package com.hj.dapp.business.mainmaterial.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hj.dapp.business.mainmaterial.model.MainMaterial;
import com.hj.dapp.business.mainmaterial.service.MainMaterialService;
import com.hj.dapp.common.request.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.swing.plaf.PanelUI;
import java.util.List;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2024/1/27
 */
@RestController
@RequestMapping("/mainmaterial")
public class MainMaterialController {
    @Autowired
    private MainMaterialService mainMaterialService;

    @GetMapping("/get/{id}")
    public MainMaterial get(@PathVariable("id") Long id) {
        return mainMaterialService.get(id);
    }
    @PutMapping("/save")
    public void save(@RequestBody MainMaterial mainMaterial) {
        mainMaterialService.save(mainMaterial);
    }
    @PostMapping("/page")
    public IPage<MainMaterial> page(@RequestBody PageRequest<MainMaterial> pageRequest) {
        return mainMaterialService.page(pageRequest);
    }
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
        mainMaterialService.delete(id);
    }
    @PostMapping("/edit")
    public void edit(@RequestBody MainMaterial mainMaterial) {
        mainMaterialService.edit(mainMaterial);
    }
    @GetMapping("/list/{categoryId}")
    public List<MainMaterial> list(@PathVariable("categoryId") Long categoryId) {
        return mainMaterialService.list(categoryId);
    }


}
